Examining racial discrimination in the US job market

Background

Racial discrimination continues to be pervasive in cultures throughout the world. Researchers examined the level of racial discrimination in the United States labor market by randomly assigning identical résumés black-sounding or white-sounding names and observing the impact on requests for interviews from employers.

Data

In the dataset provided, each row represents a resume. The 'race' column has two values, 'b' and 'w', indicating black-sounding and white-sounding. The column 'call' has two values, 1 and 0, indicating whether the resume received a call from employers or not.

Note that the 'b' and 'w' values in race are assigned randomly to the resumes.

Exercise

You will perform a statistical analysis to establish whether race has a significant impact on the rate of callbacks for resumes.

Answer the following questions in this notebook below and submit to your Github account.

  1. What test is appropriate for this problem? Does CLT apply?
  2. What are the null and alternate hypotheses?
  3. Compute margin of error, confidence interval, and p-value.
  4. Discuss statistical significance.

You can include written notes in notebook cells using Markdown:

Resources



In [3]:
import pandas as pd
import numpy as np
from scipy import stats

In [4]:
data = pd.io.stata.read_stata('data/us_job_market_discrimination.dta')

In [5]:
# number of callbacks for balck-sounding names
sum(data[data.race=='b'].call)


Out[5]:
157.0

What test is appropriate for this problem? Does CLT apply?


In [6]:
data.head()


Out[6]:
id ad education ofjobs yearsexp honors volunteer military empholes occupspecific ... compreq orgreq manuf transcom bankreal trade busservice othservice missind ownership
0 b 1 4 2 6 0 0 0 1 17 ... 1 0 1 0 0 0 0 0 0
1 b 1 3 3 6 0 1 1 0 316 ... 1 0 1 0 0 0 0 0 0
2 b 1 4 1 6 0 0 0 0 19 ... 1 0 1 0 0 0 0 0 0
3 b 1 3 4 6 0 1 0 1 313 ... 1 0 1 0 0 0 0 0 0
4 b 1 3 3 22 0 0 0 0 313 ... 1 1 0 0 0 0 0 1 0 Nonprofit

5 rows × 65 columns


In [17]:
# Retrieve raca and call data.
race_call = data[['race','call']]
race_call_black = race_call[race_call.race=='b']
race_call_white = race_call[race_call.race=='w']

In [18]:
len(race_call_black),len(race_call_white)


Out[18]:
(2435, 2435)

Ans:- It is binomial distribution.

p_w = probability of success of white person. p_b = probability of success of black person.


In [19]:
p_b = len(race_call_black[race_call_black.call==1])/len(race_call_black)
p_b


Out[19]:
0.06447638603696099

In [20]:
p_w= len(race_call_white[race_call_white.call==1])/len(race_call_white)
p_w


Out[20]:
0.09650924024640657
  • Condition Check:
    • np >= 10
    • n(1-p) > 10

In [21]:
print(len(race_call_white)*p_w)
print(len(race_call_white)*(1-p_w))


print(len(race_call_black)*p_b)
print(len(race_call_black)*(1-p_b))


235.0
2200.0
157.0
2278.0

Above conditions are satisfied so CLT is applicable.

=======================================================================================================================

What are the null and alternate hypotheses?

Null Hypothesis: there is no racial discrimination. (p_b = p_w) Alternate Hypothesis : There is. (p_b != p_w)

=======================================================================================================================

Compute margin of error, confidence interval, and p-value.

Assume 95% confidence interval. So the critical value = 1.96.

Margin of Error =


In [23]:
import math
z = 1.96
margin_of_error = z*math.sqrt(p_w*(1-p_w)/len(race_call_white)+p_b*(1-p_b)/len(race_call_black))
margin_of_error


Out[23]:
0.015255406349886438

The confidence interval is: p1 − p2 ± (margin of error)


In [24]:
[p_w - p_b - z * margin_of_error,
 p_w - p_b + z * margin_of_error]


Out[24]:
[0.0021322577636681654, 0.061933450655223]

In [29]:
from statsmodels.stats.proportion import proportions_ztest as pz
white_call = len(race_call_white[race_call_white.call==1])
black_call = len(race_call_black[race_call_black.call==1])

zstat,p_value =  pz(np.array([white_call,black_call]),np.array([len(race_call_white),len(race_call_black)]),value=0)

if p_value < 0.05:
    print ("Null Hypotesis Rejected.\nThere is racial discrimination")


Null Hypotesis Rejected.
There is racial discrimination

=======================================================================================================================

Discuss statistical significance.

Since the null hypothesis is rejected due to the small p-value, race does have an impact on the rate at which applicants are accepted for interviews by employers.


In [ ]:


In [ ]:


In [ ]:


In [ ]: